<?php
namespace app\mall\model;

use think\Model;

class Goods extends Model
{
    
    static function base($query)
    {
        $query->where(['audit' => 1, 'closed' => 0, 'delete_time' => 0]);
    }
    
    
    
    protected function before_find(&$records, $options)
    {
        foreach ($records as &$record) {
           
            if ($record['photo']) $record['photo'] = explode(',', $record['photo']);
            if ($record['details']) $record['details'] = html_entity_decode($record['details']);
            // $record['monthly_sales_count'] = $redis->zscore('monthly_sales:' . date('Ym'), $record['goods_id']) ?: '0';
        }
    }
    
     public function getBrand()
    {
        return $this->belongsTo('Brand');
    }
}